"use server"
import { Flex } from "antd"
import Title from "antd/es/typography/Title"
import QuestionBankList from "@/components/question-bank-list"
import { listQuestionBankVOByPage } from "@/api/question-bank"
import "./index.css"

/**
 * 题库大全页面
 */
export default async function BanksPage() {
  let questionBankList: QuestionBankVO[] = []

  try {
    const res = await listQuestionBankVOByPage({
      pageSize: 200,
      sortField: "createTime",
      sortOrder: "descend"
    })
    questionBankList = res.data.records ?? []
  } catch (error) {
    console.error("获取题库失败，" + error)
  }

  return (
    <div id="banks-page" className="max-width-content">
      <Flex justify="space-between" align="center">
        <Title level={3}>题库大全</Title>
      </Flex>
      <QuestionBankList questionBankList={questionBankList} />
    </div>
  )
}
